#include <stdio.h>
#include <strings.h>


int main(int argc, char**argv)
{
    //打开文件
    FILE*fp = fopen(argv[1], "a+");
    if(fp == NULL)
    {
        perror("fopen error:");
        return -1;
    }

    char class[32] = {0};
    int num;
    char name[32] = {0};
    scanf("%s%d%s", class, &num, name);
    //HF240401-123-pxl

    int re = printf("%s-%d-%s\n", class, num, name);
    printf("re = %d\n", re);
    re = fprintf(fp," %s-%d-%s \n",class, num, name);
    printf("re = %d\n", re);

    char buf[10] = {0};
    re = sprintf(buf, "%s-%d-%s\n",class, num, name);
    printf("buf = %s\n", buf);
    printf("re = %d\n", re);
    
    re = snprintf(buf, 10,"%s-%d-%s\n",class, num, name);
    printf("buf = %s\n", buf);
    printf("re = %d\n", re);
    fclose(fp);

   
}